Skip to main content

ListOffsetBefore

Type​

operator

Summary​

Find the first or last occurrence of Needle within the head of Haystack Target:An expression which evaluates to a List.

Syntax​

the ( first | last ) offset of <Needle> before <Before> in <Haystack>

Description​

Use the offset of… before to find where a particular sub-list occurs within a list. Haystack is scanned for a sequence of elements that are equal to the elements of Needle, stopping before the position Before, and the position of the start of the sequence found is returned. If no sub-list of Haystack before the position Before is equal to Needle, the return value is 0. If neither "first" nor "last" is specified, the last matching subsequence is found.

Parameters​

NameTypeDescription

Needle

An expression which evaluates to List.

Before

An expression which evaluates to a valid index in Target.

Examples​

variable tVar as List
variable tOffset as Number
put ["a", "b", "c", "d", "b","c"]
put the offset of ["b","c"] before 5 in tVar into tOffset
--tOffset contains 2

put the first offset of ["b","c"] before 6 in tVar into tOffset
--tOffset contains 2

Value​

NameTypeDescription

return

Returns the index in Haystack.

Thank you for your feedback!

Was this page helpful?